package org.jivesoftware.smackx.workgroup.packet;

import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.TimeZone;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider;
import org.xmlpull.v1.XmlPullParser;

public class OccupantsInfo extends IQ
{
  public static final String ELEMENT_NAME = "occupants-info";
  public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
  private static final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
  private final Set<OccupantInfo> occupants;
  private String roomID;

  static
  {
    UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0"));
  }

  public OccupantsInfo(String paramString)
  {
    this.roomID = paramString;
    this.occupants = new HashSet();
  }

  // ERROR //
  public String getChildElementXML()
  {
    // Byte code:
    //   0: new 64	java/lang/StringBuilder
    //   3: dup
    //   4: invokespecial 65	java/lang/StringBuilder:<init>	()V
    //   7: astore_1
    //   8: aload_1
    //   9: ldc 67
    //   11: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   14: ldc 14
    //   16: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   19: ldc 73
    //   21: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   24: ldc 17
    //   26: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   29: pop
    //   30: aload_1
    //   31: ldc 75
    //   33: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   36: aload_0
    //   37: getfield 51	org/jivesoftware/smackx/workgroup/packet/OccupantsInfo:roomID	Ljava/lang/String;
    //   40: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   43: ldc 77
    //   45: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   48: pop
    //   49: aload_0
    //   50: getfield 56	org/jivesoftware/smackx/workgroup/packet/OccupantsInfo:occupants	Ljava/util/Set;
    //   53: astore 4
    //   55: aload 4
    //   57: monitorenter
    //   58: aload_0
    //   59: getfield 56	org/jivesoftware/smackx/workgroup/packet/OccupantsInfo:occupants	Ljava/util/Set;
    //   62: invokeinterface 83 1 0
    //   67: astore 6
    //   69: aload 6
    //   71: invokeinterface 89 1 0
    //   76: ifne +28 -> 104
    //   79: aload 4
    //   81: monitorexit
    //   82: aload_1
    //   83: ldc 91
    //   85: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   88: ldc 14
    //   90: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   93: ldc 93
    //   95: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   98: pop
    //   99: aload_1
    //   100: invokevirtual 96	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   103: areturn
    //   104: aload 6
    //   106: invokeinterface 100 1 0
    //   111: checkcast 6	org/jivesoftware/smackx/workgroup/packet/OccupantsInfo$OccupantInfo
    //   114: astore 7
    //   116: aload_1
    //   117: ldc 102
    //   119: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   122: pop
    //   123: aload_1
    //   124: ldc 104
    //   126: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   129: pop
    //   130: aload_1
    //   131: aload 7
    //   133: invokevirtual 107	org/jivesoftware/smackx/workgroup/packet/OccupantsInfo$OccupantInfo:getJID	()Ljava/lang/String;
    //   136: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   139: pop
    //   140: aload_1
    //   141: ldc 109
    //   143: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   146: pop
    //   147: aload_1
    //   148: ldc 111
    //   150: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   153: pop
    //   154: aload_1
    //   155: aload 7
    //   157: invokevirtual 114	org/jivesoftware/smackx/workgroup/packet/OccupantsInfo$OccupantInfo:getNickname	()Ljava/lang/String;
    //   160: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   163: pop
    //   164: aload_1
    //   165: ldc 116
    //   167: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   170: pop
    //   171: aload_1
    //   172: ldc 118
    //   174: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   177: pop
    //   178: aload_1
    //   179: getstatic 35	org/jivesoftware/smackx/workgroup/packet/OccupantsInfo:UTC_FORMAT	Ljava/text/SimpleDateFormat;
    //   182: aload 7
    //   184: invokevirtual 122	org/jivesoftware/smackx/workgroup/packet/OccupantsInfo$OccupantInfo:getJoined	()Ljava/util/Date;
    //   187: invokevirtual 126	java/text/SimpleDateFormat:format	(Ljava/util/Date;)Ljava/lang/String;
    //   190: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   193: pop
    //   194: aload_1
    //   195: ldc 128
    //   197: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   200: pop
    //   201: aload_1
    //   202: ldc 130
    //   204: invokevirtual 71	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   207: pop
    //   208: goto -139 -> 69
    //   211: astore 5
    //   213: aload 4
    //   215: monitorexit
    //   216: aload 5
    //   218: athrow
    //
    // Exception table:
    //   from	to	target	type
    //   58	82	211	finally
    //   104	216	211	finally
  }

  public Set<OccupantInfo> getOccupants()
  {
    return Collections.unmodifiableSet(this.occupants);
  }

  public int getOccupantsCount()
  {
    return this.occupants.size();
  }

  public String getRoomID()
  {
    return this.roomID;
  }

  public static class OccupantInfo
  {
    private String jid;
    private Date joined;
    private String nickname;

    public OccupantInfo(String paramString1, String paramString2, Date paramDate)
    {
      this.jid = paramString1;
      this.nickname = paramString2;
      this.joined = paramDate;
    }

    public String getJID()
    {
      return this.jid;
    }

    public Date getJoined()
    {
      return this.joined;
    }

    public String getNickname()
    {
      return this.nickname;
    }
  }

  public static class Provider
  implements IQProvider
  {
    private OccupantsInfo.OccupantInfo parseOccupantInfo(XmlPullParser paramXmlPullParser)
      throws Exception
    {
      int i = 0;
      String str1 = null;
      String str2 = null;
      Date localDate = null;
      while (true)
      {
        int j;
        do
          while (true)
          {
            while (true)
            {
              while (true)
              {
                if (i != 0)
                  return new OccupantsInfo.OccupantInfo(str1, str2, localDate);
                j = paramXmlPullParser.next();
                if ((j != 2) || (!("jid".equals(paramXmlPullParser.getName()))))
                  break;
                str1 = paramXmlPullParser.nextText();
              }
              if ((j != 2) || (!("nickname".equals(paramXmlPullParser.getName()))))
                break;
              str2 = paramXmlPullParser.nextText();
            }
            if ((j != 2) || (!("joined".equals(paramXmlPullParser.getName()))))
              break;
            localDate = OccupantsInfo.access$1().parse(paramXmlPullParser.nextText());
          }
        while ((j != 3) || (!("occupant".equals(paramXmlPullParser.getName()))));
        i = 1;
      }
    }

    public IQ parseIQ(XmlPullParser paramXmlPullParser)
      throws Exception
    {
      if (paramXmlPullParser.getEventType() != 2)
        throw new IllegalStateException("Parser not in proper position, or bad XML.");
      OccupantsInfo localOccupantsInfo = new OccupantsInfo(paramXmlPullParser.getAttributeValue("", "roomID"));
      int i = 0;
      while (true)
      {
        int j;
        do
          while (true)
          {
            if (i != 0)
              return localOccupantsInfo;
            j = paramXmlPullParser.next();
            if ((j != 2) || (!("occupant".equals(paramXmlPullParser.getName()))))
              break;
            OccupantsInfo.access$0(localOccupantsInfo).add(parseOccupantInfo(paramXmlPullParser));
          }
        while ((j != 3) || (!("occupants-info".equals(paramXmlPullParser.getName()))));
        i = 1;
      }
    }
  }
}